<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8" />
    <title>积分兑换-{eyou:global name='web_name' /}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    {eyou:static file="users/skin/css/basic.css"/}
    {eyou:static file="users/skin/css/eyoucms.css"/}
    <!-- 新样式 2020-11-25 -->
    {eyou:static file="users/skin/css/element/index.css" /}
    {eyou:static file="users/skin/css/e-user.css" /}
    {eyou:include file="users/skin/css/diy_css.htm"/}

    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
    {eyou:static file="/public/static/common/js/tag_global.js"/}
    {eyou:static file="/public/static/common/js/mobile_global.js"/}
</head>

<body class="centre">
<!-- 头部信息 -->
<div class="ey-header-status">
	<div class="header-status-l">
		<a href="javascript:history.go(-1)"><i class="el-icon-arrow-left"></i></a>
	</div>
	<div class="header-status-m">积分兑换</div>
	<div class="header-status-r">
		<a href="{eyou:url link='user/Users/index' /}"><i class="el-icon-user"></i></a>
	</div>
</div>
<!-- 头部信息结束 -->
<div class="h50"></div>
<div class="oper-row border-b-1-e">
    <!-- 足迹导航栏 -->
    <div class="oper-row-roll">
        <a class="oper-row-button active" id="a_changeGift1" onclick="changeGift(1);"> 全部商品 </a>
        <a class="oper-row-button" id="a_changeGift2" onclick="changeGift(2);"> 兑换记录 </a>
    </div>
    <!-- 足迹导航栏 -->
</div>

<div class="ey-container">
	<div class="ey-con">
        <!-- 中部 -->
        <div class=" pro-list">
            {eyou:empty name="$list"}
            <div class="ey-row min-hg-c-92 flex flex-center">
                <div class="tc mt-92">
                    <p class=""><img id='litpic_img' src="{eyou:static file='users/skin/images/null-data.png' /}"/></p>
                    <p class="fc9">当前暂无兑换商品哦~</p>
                </div>
            </div>
            {eyou:else/}
            <div class="ey-row min-hg-c-92 bgfff ptb0">
                {eyou:volist name="$list" id="vo" key="k"}
                <div class="balances">
                    <a class="balances-pic" href="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}">
                        <img class="pic" src="{$vo.litpic}">
                    </a>
                    <div class="balances-info">
                        <div class="title">
                            <a href="{:url('user/Memgift/users_gift_detail',['gift_id'=>$vo.gift_id])}">{$vo.giftname}</a>
                        </div>
                        <div><span>{$vo.score}{$score_name}</span></div>
                    </div>
                    <div class="balances-num">
                        {eyou:if condition='$users.scores >= $vo.score'}
                        {eq name='$vo.type' value='-1'}
                        <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_shiwu',['gift_id'=>$vo.gift_id])}" onclick="jumpInfo(this)">立即兑换</a>
                        {else/}
                        <a href="javascript:void(0)" class="okgo" data-url="{:url('user/Memgift/users_gift_vip',['gift_id'=>$vo.gift_id])}" onclick="jumpVip(this)">立即兑换</a>
                        {/eq}
                        {eyou:else /}
                        <a class="okgo nones">{$score_name}不足</a>
                        {/eyou:if}
                    </div>
                </div>
                {/eyou:volist}
            </div>
            {/eyou:empty}
        </div>
        <div class="order-list" style="display: none;">
            {eyou:empty name="$order_list"}
            <div class="ey-row min-hg-c-92 flex flex-center">
                <div class="tc mt-92">
                    <p class=""><img id='litpic_img' src="{eyou:static file='users/skin/images/null-data.png' /}"/></p>
                    <p class="fc9">当前暂无兑换商品哦~</p>
                </div>
            </div>
            {eyou:else/}
            <div class="ey-row min-hg-c-92 bgfff ptb0">
                {eyou:volist name="$order_list" id="vo" }
                <div class="balances">
                    <div class="balances-pic">
                        <img class="pic" src="{$vo.litpic}">
                    </div>
                    <div class="balances-info">
                        <div  class="title">
                            {$vo.giftname}
                        </div>
                        <div><span class="mr10">{$vo.score}{$score_name}{eyou:if condition="$vo.status eq 2"}[{$score_name}已返还]{/eyou:if}</span><span>{$vo.add_time|MyDate="Y-m-d H:i",###}</span></div>
                    </div>
                    <div class="list_z tc">
                        {eyou:if condition="$vo.status eq 1"}
                        <span style="color: #67c23a">已发货</span>
                        {elseif condition="$vo.status eq 2"}
                        <span style="color: #F00">发货取消</span>
                        {else /}
                        <span style="color: #333">待发货</span>
                        {/eyou:if}
                    </div>
                </div>
                {/eyou:volist}
            </div>
            {/eyou:empty}
        </div>
	</div>
</div>
<script>
	function changeGift(n) {
		if (1 == n){
		    $('#a_changeGift1').addClass('active');
		    $('#a_changeGift2').removeClass('active');
		    $('.pro-list').show();
		    $('.order-list').hide();
		} else{
            $('#a_changeGift2').addClass('active');
            $('#a_changeGift1').removeClass('active');
            $('.pro-list').hide();
            $('.order-list').show();
		}
    }
    //兑换实物
    function jumpInfo(obj){
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goinfo',
            title: '填写快递信息',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3,'#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['90%','288px'],
            content: url
        });
    }
    //打开详情页
    function goDetail(obj) {
        //iframe窗
        var url = $(obj).data('url');
        var index = layer.open({
            type: 2,
            id: 'iframe_goDetail',
            title: '商品详情',
            fixed: true, //不固定
            shadeClose: false,
            shade: [0.3, '#000'],
            maxmin: false, //开启最大化最小化按钮
            closeBtn: 1,
            area: ['700px', '99%'],
            content: url,
        });
    }
    //兑换会员
    function jumpVip(obj) {
        var url = $(obj).data('url');
        layer.confirm('确定要兑换商品？', {
            skin: 'xin-demo-btn',
            closeBtn: 0,
            shadeClose: true
        }, function() {
            $.ajax({
                url: url,
                type: 'POST',
                dataType: 'JSON',
                data: {
                    long: 0
                },
                success: function(res) {
                    if (1 == res.code) {
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            window.location.reload();
                        });
                    } else if (res.code == 2) {
                        layer.confirm(res.msg, {
                            btn: ['继续兑换', '取消'] //按钮
                        }, function() {
                            $.ajax({
                                url: url,
                                type: 'POST',
                                dataType: 'JSON',
                                data: {
                                    long: 1
                                },
                                success: function(res) {
                                    if (1 == res.code) {
                                        layer.msg(res.msg, {
                                            icon: 1,
                                            time: 1000
                                        }, function() {
                                            window.location.reload();
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2,
                                            time: 2000
                                        });
                                    }
                                },
                                error: function(e) {
                                    layer.closeAll();
                                    layer.alert(e.responseText, {
                                        icon: 5,
                                        title: false
                                    });
                                }
                            })
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000
                        });
                    }
                },
                error: function(e) {
                    layer.closeAll();
                    layer.alert(e.responseText, {
                        icon: 5,
                        title: false
                    });
                }
            })
        }, function(index) {
            layer.closeAll(index);
        });
    }
</script>
<!-- END -->